//
//  FlexLay.swift
//  flow
//
//  Created by tong on 2017/7/13.
//  Copyright © 2017年 tong. All rights reserved.
//

import UIKit
import AsyncDisplayKit


public enum FlexCenter{
    case x
    case y
    case xy
    
    public var value:ASCenterLayoutSpecCenteringOptions{
        switch self {
        case .x:
            return .X
        case .y:
            return .Y
        default:
            return .XY
        }
    }
}




public struct _justfy {
    public var value:FlexJustifyContent = FlexJustifyContent.flex_start
    public init(_ v:FlexJustifyContent) {
        self.value = v
    }
}

public struct _alignSelf {
    public var value:FlexItemAlignSelf = .flex_start
    public init(_ v:FlexItemAlignSelf) {
        self.value = v
    }
}


public struct _sid{
    public var value = ""
    public init(_ v:String) {
        self.value = v
    }
}

public struct _shrink {
    public var value:Double = 1
    public init(_ v:Double) {
        self.value = v
    }
}

public let _nowrap:ASStackLayoutFlexWrap = ASStackLayoutFlexWrap.noWrap
public let _wrap:ASStackLayoutFlexWrap = ASStackLayoutFlexWrap.wrap


public struct _grow {
    public var value:Double = 1
    public init(_ v:Double) {
        self.value = v
    }
}




public struct _padding {
    public var values = [CGFloat]()
    public var inset:UIEdgeInsets
    public init(_ paddings:CGFloat...) {
        switch paddings.count {
        case 2:
            top = paddings[0]; left = paddings[1];  bottom = paddings[0]; right = paddings[1];
        case 3:
            top = paddings[0]; left = paddings[1];  bottom = paddings[2]; right = paddings[1];
        case 4:
            top = paddings[0]; left = paddings[1];  bottom = paddings[2]; right = paddings[3];
        case 1:
            top = paddings[0]; left = paddings[0];  bottom = paddings[0]; right = paddings[0];
        default:
            break
        }
        self.inset = UIEdgeInsets(top: top, left: left, bottom: bottom, right: right)
    }
    
    
    public init(_ paddings:[CGFloat]) {
        switch paddings.count {
        case 2:
            top = paddings[0]; left = paddings[1];  bottom = paddings[0]; right = paddings[1];
        case 3:
            top = paddings[0]; left = paddings[1];  bottom = paddings[2]; right = paddings[1];
        case 4:
            top = paddings[0]; left = paddings[1];  bottom = paddings[2]; right = paddings[3];
        case 1:
            top = paddings[0]; left = paddings[0];  bottom = paddings[0]; right = paddings[0];
        default:
            break
        }
        self.inset = UIEdgeInsets(top: top, left: left, bottom: bottom, right: right)
    }
    
    public var top:CGFloat = 0
    public var left:CGFloat = 0
    public var right:CGFloat = 0
    public var bottom:CGFloat = 0
    
    
}
//
//public func isNumber(value:Any)->(Bool,Double){
//    if let v = value as? Int
//    {
//        return (true,Double(v))
//    }
//    if let v = value as? Float
//    {
//        return (true,Double(v))
//    }
//    if let v = value as? Double
//    {
//        return (true,Double(v))
//
//    }
//    if let v = value as? CGFloat
//    {
//        return (true,Double(v))
//    }
//    return (false,0)
//}
//public func isString(value:Any)->(Bool,String){
//    if let v = value as? String
//    {
//        return (true,v)
//    }
//    return (false,"")
//}
//
//
//
